#
# StartTCL: n
#
# ====================================
#
# Dire Maul PVP Arena script
#
# ====================================
#
# Modified by Delfin
# 01.05.06
#
# Start-TCL 0.9.4 compatible
#

proc ::WoWEmu::Commands::pvp2 { player cargs } {
	variable userpos
	set player_name [ ::GetName $player ]
	set option [ lindex $cargs 0 ]

	if { $option == "" } {
		set msg "\nDire Maul PVP Arena: \nTo ENTER the pvp arena type .pvp2 enter \nTo LEAVE the pvp arena type .pvp2 leave \nFor information type .pvp2 info"
	} else {
		switch $option {
			"enter" {
				if { ! [ ::GetQFlag $player "jailed" ] } {
					if { ! [ ::GetQFlag $player "pvparena" ] } {
						set userpos($player_name) [ lindex [ ::GetPos $player ] ]
						::SetQFlag $player "pvparena"
						::Teleport $player 1 -3882.659424 1095.236084 154.787018
					} else {
						return [ ::Texts::Get "already_there" ]
					}
				} else {
					return [ ::Texts::Get "no_enter_while_jailed" ]
				}
			}
			"leave" {
				if { ! [ ::GetQFlag $player "jailed" ] } {
					if { ! [ ::GetQFlag $player "pvparena" ] } {
						return [ ::Texts::Get "not_in_arena" ]
					}

					::ClearQFlag $player "pvparena"
					set m [ lindex $userpos($player_name) 0 ]
					set x [ lindex $userpos($player_name) 1 ]
					set y [ lindex $userpos($player_name) 2 ]
					set z [ lindex $userpos($player_name) 3 ]
					::Teleport $player $m $x $y $z 

					if { [ lindex [ ::GetPos $player ] 1 ] == $x } {
						set userpos($player_name) {}
					} else {
						return [ ::Texts::Get "cant_teleport" ]
					}
				} else { 
					return [ ::Texts::Get "no_enter_while_jailed" ]
				}
			}
			"info" {
				set msg [ ::Texts::Get "pvp_info" ]
			}
		}
	}
}

::Custom::AddCommand {"pvp2" ::WoWEmu::Commands::pvp2 0}

